clear all;

load('mig.mat');

mig_lb(1:nz)=0;
mig_ub(1:nz)=0;
theta=0.8;
theta_index=find(gridtheta==theta);

for i=1:nz
    temp=find(mig_1to2(i,:,theta_index)==1);
    if ~isempty(temp)
        mig_lb(i)=min(temp);
        mig_ub(i)=max(temp); 
    end
end

index_lb=find(mig_lb~=0);
index_ub=find(mig_ub~=0);

x_highkappa=gridb(mig_lb(index_lb));
y_highkappa=gridz(index_lb);

x_highkappa=flip(x_highkappa(1:end-1));
y_highkappa=flip(y_highkappa(1:end-1));


save('result_OA9_A.mat','x_highkappa','y_highkappa')